package m.jclecai.com.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import m.jclecai.com.R;
import m.jclecai.com.bean.OpenGradeBean;

/**
 * Created by hp on 2017/3/15.
 */

public class LotteryDetailsAdapter extends BaseAdapter{

    private Context context;
    private OpenGradeBean.PrizeLevel prizeLevel;

    public void setData(Context context, OpenGradeBean.PrizeLevel prizeLevel){
        this.context = context;
        this.prizeLevel = prizeLevel;
    }

    @Override
    public int getCount() {
        return prizeLevel.getName().size();
    }

    @Override
    public Object getItem(int position) {
        return prizeLevel.getName().get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if(convertView == null){
            holder = new ViewHolder();
            convertView = View.inflate(context, R.layout.lottery_details_item,null);
            holder.tv_name = (TextView) convertView.findViewById(R.id.tv_name);
            holder.tv_nums = (TextView) convertView.findViewById(R.id.tv_nums);
            holder.tv_prize = (TextView) convertView.findViewById(R.id.tv_prize);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
             holder.tv_name.setText(prizeLevel.getName().get(position));
             holder.tv_nums.setText(prizeLevel.getNums().get(position));
             holder.tv_prize.setText(prizeLevel.getPrize().get(position));


        return convertView;
    }

    private static class ViewHolder{
        TextView tv_name;
        TextView tv_nums;
        TextView tv_prize;
    }
}






















